import $V from './$V';

export default function roc(price, length) {
    let ROCValue = $V.init(price.length,0);
    ROCValue = $V.copy_by_range(
        ROCValue,
        $V.arange(length,price.length),
        $V.mul_constant(
            $V.div(
                $V.sub(
                    $V.subv(price,length,price.length),
                    $V.subv(price,0,price.length-length)
                ),
                $V.subv(price,0,price.length-length)),
            100));
    return ROCValue;
}
